﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Microsoft.Windows.UserControls"
                    xmlns:viewModels="clr-namespace:Microsoft.Windows.UserControls.ViewModels"
                    xmlns:converters="clr-namespace:Microsoft.Windows.UserControls.Core.Converters"
                    >
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Microsoft.Windows.UserControls.Wpf;component/Themes/DefaultColors.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/Microsoft.Windows.UserControls.Wpf;component/Themes/Common.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type local:LoggerView}">
        <Setter Property="Background" Value="{StaticResource ControlBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ActiveBorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="3"/>
        <Setter Property="Foreground" Value="{StaticResource ControlTextBrush}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:LoggerView}">
                    <Border x:Name="loggerViewBorder" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Visibility="{TemplateBinding TitleVisibility}"
                            SnapsToDevicePixels="true" >
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Border Background="{StaticResource HighlightBrush}">
                                <TextBlock Text="{TemplateBinding Title}"
                                           Margin="6,3"
                                           Foreground="{StaticResource HighlightTextBrush}"/>
                            </Border>
                            <ScrollViewer x:Name="loggerViewScrollViewer" 
                                          Grid.Row="2"
                                          Background="{TemplateBinding Background}" 
                                          CanContentScroll="false" 
                                          Focusable="false" 
                                          HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" 
                                          VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                                          Padding="{TemplateBinding Padding}" 
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                          >
                                <ItemsPresenter/>
                            </ScrollViewer>
                        </Grid>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" TargetName="loggerViewBorder" Value="{StaticResource ControlBrush}"/>
                        </Trigger>
                        <Trigger Property="VirtualizingPanel.IsVirtualizing" Value="true">
                            <Setter Property="CanContentScroll" TargetName="loggerViewScrollViewer" Value="true"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <Style.Triggers>
            <Trigger Property="VirtualizingPanel.IsVirtualizing" Value="true">
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel/>
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>

    </Style>

</ResourceDictionary>